package com.black.web.app.store;


import com.black.app.domain.req.store.query.AppStoreProductSpecificationsQueryReq;
import com.black.app.domain.resp.store.AppStoreProductSpecificationsResp;
import com.black.app.domain.store.AppStoreProductSpecifications;
import com.black.app.service.store.AppStoreProductSpecificationsService;
import com.black.common.core.domain.R;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "app-商品规格相关Api")
@RestController
@RequestMapping("/app/specifications")
public class AppStoreProductSpecificationsController {

    @Autowired
    private AppStoreProductSpecificationsService appStoreProductSpecificationsService;


    @ApiOperation(value = "分页查询规格信息")
    @GetMapping("/list")
    public R<PageInfo<AppStoreProductSpecificationsResp>> paginationQuery(AppStoreProductSpecificationsQueryReq req) {
        PageInfo<AppStoreProductSpecificationsResp> resp = this.appStoreProductSpecificationsService.paginationQuery(req);
        return R.ok(resp);
    }

    @ApiOperation(value = "根据id查询")
    @GetMapping("/{id}")
    public R<AppStoreProductSpecificationsResp> findById(@PathVariable(value = "id") Long id){
        AppStoreProductSpecificationsResp resp = this.appStoreProductSpecificationsService.findById(id);
        return R.ok(resp);
    }

    @ApiOperation(value = "根据商品id查询")
    @GetMapping("/product/{pid}")
    public R<List<AppStoreProductSpecifications>> findByPid(@PathVariable(value = "pid") Integer pid){
        List<AppStoreProductSpecifications> list = this.appStoreProductSpecificationsService.findByPid(pid);
        return R.ok(list);
    }
}
